package nuc.ss.wl.controller;

import nuc.ss.wl.entity.Special_Situation;
import nuc.ss.wl.entity.Student;
import nuc.ss.wl.service.Special_SituationService;

import nuc.ss.wl.service.impl.Special_SituationServiceImpl;
import nuc.ss.wl.utils.WebUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.UUID;

public class Special_SituationServlet extends BaseServlet {
        private Special_SituationService service = new Special_SituationServiceImpl();
    protected void findAll(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
        List<Special_Situation> list = service.findAll();
        request.setAttribute("List", list);
        request.getRequestDispatcher("/pages/manager/special_manager.jsp").forward(request, response);
    }

    protected void delete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int sno = WebUtil.parseInt(request.getParameter("sno"), 0);
        service.delete(sno);
        response.sendRedirect(request.getContextPath() + "/special_situationServlet?action=findAll");
    }
    protected void addStudent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Special_Situation special_situation = WebUtil.populateParams(request.getParameterMap(), new Special_Situation());
        service.add(special_situation);
        response.sendRedirect(request.getContextPath() + "/special_situationServlet?action=findAll");
    }
}
